package mybatis.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import mybatis.entity.Game;
import mybatis.service.GamesService;
import mybatis.service.impl.GamesServiceImpl;
import mybatis.service.impl.OrderServiceImpl;

@WebServlet("/popular/*")
public class PopularServlet extends BaseServlet {
	private GamesService service;
	{
		service = applicationContext.getBean("gamesServiceImpl", GamesServiceImpl.class);
	}
	public void findByPage(HttpServletRequest request, HttpServletResponse response) {
		String tids = request.getParameter("tid");
		int tid = Integer.parseInt(tids) ;
		int currentPage = Integer.parseInt(request.getParameter("currentPage"));
		List<Game> list = service.findPageByTid(tid, currentPage);
		PageInfo<Game> page = new PageInfo(list);
		try {
			responseJson(response,page);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
